{extend name="Index/index" /}
{block name="s"}
 <form class="searchform" action="{:url('admin/Film/select')}" method="post">
             <span>
                <input type="text" class="form-control" name="k" placeholder="填入搜索关键词" />
                <button type="submit" class="btn  pull-left" style="position: relative;
  top: 7px;left:10px;">搜索</button>
             </span>   

            </form>
{/block}
{block name="main"}
<script>
    // 设置弹框参数
    toastr.options = {
        closeButton: true,// 是否显示关闭按钮
        progressBar: true,// 实现显示计时条
        timeOut: "3000",  // 自动关闭时间
        positionClass: "toast-bottom-left" // 提示位置
        // positionClass: "toast-top-full-width" // 提示位置
        // toast-top-full-width 顶端，宽度铺满整个屏幕
        // toast-top-right  顶端右边
    };

    $(function () {
        // 触发 删除用户
        $('.del-btn').click(function () {
            var ac_id = $(this).attr('data-id');
            // console.log('删除的ID: ' + $(this).attr('data-id'));

            if (confirm('你确定要 [ 删除 ] 吗?')) {
                var obj = $(this).parents('tr');
                // console.log(obj);
                delAjax(ac_id, obj);
            }
        });
    });

    // 执行AJAX删除
    function delAjax(id, obj) {
        $.ajax({
            type: 'delete',
            url: '/filmdelete/' + id,
            dataType: 'json',
            success: function (data) {
//                 console.log(data);
                if (data.status) {
                    toastr.success(data.info);
                    obj.remove();
                } else {
                    toastr.error(data.info, 'FBI WARING: ');
                }
            },
            error: function () {
                alert('AJAX操作失败');
            }
        });
    }
</script>

    <h2>
        影片管理
        <small>
            <i class="icon-double-angle-right"></i>
            <span style="color: deepskyblue;">影片列表</span>
        </small>
    </h2>

    <table class="table table-hover bg-info">
        <thead>
        <tr>
            <th>影片ID</th>
            <th>影片名称</th>
            <th>影片时长</th>
            <th>上映时间</th>
            <th>语言</th>
            <th>国家</th>
            <th>评分</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
     {volist name="data" id="v"}
        <tr>
            <td>{$v.id}</td>
            <td>{$v.filmname}</td>
            <td>{$v.time}</td>
            <td>{$v.year}</td>
            <td>
             {eq name="$v.tongue" value="0"}中文{/eq}   
             {eq name="$v.tongue" value="1"}英文{/eq}   
             {eq name="$v.tongue" value="2"}日语{/eq}   
             {eq name="$v.tongue" value="3"}韩语{/eq}   
            </td>
            <td>
            {eq name="$v.state" value="0"}中国{/eq}
            {eq name="$v.state" value="1"}美国{/eq}
            {eq name="$v.state" value="2"}日本{/eq}
            {eq name="$v.state" value="3"}韩国{/eq}
            {eq name="$v.state" value="4"}印度{/eq}    
            </td>
            <td>{$v.grade}</td>
            <td>
                <a class="btn abcd"  data-id="{$v.id}"  data-toggle="modal"
                data-target="#myModal">详情</a>
                <a href="filmedit/{$v.id}">修改</a>
                <button class="btn btn-danger del-btn" data-id="{$v.id}">删除</button>
                
            </td>
        </tr>
    {/volist}    
    <script>
       $(function(){
         $('.abcd').click(function(){
            var id = $(this).attr('data-id');
            console.log(id);
            $.ajax({
                type:'get',
                url: "infooo",
                data:"id="+id,
                success: function(data){
                    console.log(data);
                    $('#person').html(data[0]['person']);
                    $('#filmname').html(data[0]['filname']);
                    $('#image').attr('src', '/static/image/'+data[0]['filmimg']);
                    $('#year').html(data[0]['year']);
                    $('#info').html(data[0]['info']);
                    $('#count').html(data[0]['count']);
                                     }
                 
            })  
        })
     })    


    </script>    
        </tbody>


    </table>
     <table class="table">
         <tr>
             <td>{$data->render()}</td>
         </tr>
     </table>


<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">影片详情</h4>
      </div>
      <div class="modal-body">
      <div class="row">
          <div class="col-md-6">
              <img id="image" src="" width="210" height="300">
          </div>
          <div class="col-md-6">
              <!--影片名称-->
              <h2 id="filmname"></h2>
              <h4>剧情简介</h4>
              <p id="info"></p>
              <h4>上映时间</h4>
              <p id="year"></p>
              <h4>播放次数</h4>
              <p id="count"></p>
              <h4>导演 / 演员</h4>
              <p id="person"></p>
          </div>
      </div>
      <div class="row">
          
      </div>
      </div>
      <div class="modal-footer">
      
        <button type="button" class="btn btn-info" data-dismiss="modal" style="border-radius:10px;">离开</button>
      </div>
    </div>
  </div>
</div>



{/block}